﻿<UserControls:ScrumUserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:Controls="clr-namespace:Microsoft.Surface.Presentation.Controls;assembly=Microsoft.Surface.Presentation"
    xmlns:CustomControl1="clr-namespace:ScrumTable.UI.View.CustomControl;assembly=ScrumTable.UI.View" 
    xmlns:Localization="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View" xmlns:UserControl="clr-namespace:ScrumTable.UI.View.Controls;assembly=ScrumTable.UI.View" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View" x:Class="ScrumTable.UI.View.WinTouch.UserControls.Tool.SearchScreen"	x:Name="UserControl" HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="1024" Height="600" Background="White">

    <Grid>
        <Grid.Resources>
            <Converter:ConverterIsEmptyString x:Key="CheckStringEmpty"/>
            <Style  TargetType="{x:Type GroupBox}">
                <Setter Property="Margin" Value="10,5,10,5"/>
                <Setter Property="Padding" Value="5"/>
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock Text="{Binding}" Foreground="Black" FontWeight="Bold"/>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style  TargetType="{x:Type Controls:SurfaceCheckBox }" BasedOn="{StaticResource {x:Type Controls:SurfaceCheckBox}}">
                <Setter Property="Margin" Value="0,2,0,2"/>
            </Style>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid Background="{StaticResource ListBoxBackgroundGrayHorizontal}" Opacity="0.5"></Grid>
        <StackPanel>
            <GroupBox Header="{Localization:Translate Uid=Search,Default=[Search]}" BorderThickness="0">
                <Grid>
                    <Controls:SurfaceTextBox Name="TxtSearch" TextChanged="OnFilterTextChanged" Width="210" HorizontalAlignment="Left" KeyUp="OnSearchKeyUp"/>
                    <Controls:SurfaceButton HorizontalAlignment="Right" Background="{StaticResource IconGlass}" Click="OnSearchClick"/>
                </Grid>
            </GroupBox>
            <GroupBox Header="{Localization:Translate Uid=Search_After,Default=[Search1]}" BorderThickness="0">
                <StackPanel>
                    <Controls:SurfaceCheckBox x:Name="CheckStorie" Content="{Localization:Translate Uid=General_UserStory,Default=[UserStory]}" IsChecked="{Binding SearchStory}"/>
                    <Controls:SurfaceCheckBox x:Name="CheckTask" Content="{Localization:Translate Uid=General_Task,Default=[Task]}" IsChecked="{Binding SearchTask}"/>
                    <Controls:SurfaceCheckBox x:Name="CheckBug" Content="{Localization:Translate Uid=General_Bug,Default=[Bug]}" IsChecked="{Binding SearchBug}"/>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="{Localization:Translate Uid=Search_In,Default=[Search2]}" BorderThickness="0">
                <StackPanel>
                    <Controls:SurfaceCheckBox x:Name="CheckTitle" Content="{Localization:Translate Uid=Search_Title,Default=[Title]}" IsChecked="{Binding CheckTitle}"/>
                    <Controls:SurfaceCheckBox x:Name="CheckDescription" Content="{Localization:Translate Uid=Search_Description,Default=[Description]}" IsChecked="{Binding CheckDescription}"/>
                    <Controls:SurfaceCheckBox x:Name="CheckAssigned" Content="{Localization:Translate Uid=Search_AssignedTo,Default=[AssignedTo]}" IsChecked="{Binding CheckAssigned}"/>
                    <Controls:SurfaceCheckBox x:Name="CheckId" Content="Id" IsChecked="{Binding CheckId}"/>
                </StackPanel>
            </GroupBox>
        </StackPanel>

        <UserControls:SurfaceDragDropListBox  MultipleColumnsRows="True"  Grid.Column="1" 
            x:Name="TasksListToDo" IsItemSelectable="False" AllowDrop="False" 
            AddOnDrop="False" ItemsSource="{Binding FoundItems}"  >
            <UserControls:SurfaceDragDropListBox.ItemTemplate>
                <DataTemplate>
                    <UserControls:ScrumItemControl DataContext="{Binding}" />
                </DataTemplate>
            </UserControls:SurfaceDragDropListBox.ItemTemplate>
        </UserControls:SurfaceDragDropListBox>

        <TextBlock FontStyle="Italic" FontSize="40" Text="{Localization:Translate Uid=Search_NoItems, Default=[NoItemFound]}" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" >
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}">
                   <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>                      
                          <MultiDataTrigger>
                               <MultiDataTrigger.Conditions>                                    
                                    <Condition Binding="{Binding ElementName=TasksListToDo, Path=Items.Count}" Value="0"/>
                                    <Condition Binding="{Binding SearchIsRunning}" Value="False"/>
                                    <Condition Binding="{Binding ElementName=TxtSearch, Path=Text, Converter={StaticResource CheckStringEmpty}}" Value="False"/>
                               </MultiDataTrigger.Conditions>
                               <Setter Property="Visibility" Value="Visible" />
                         </MultiDataTrigger>
                    </Style.Triggers>                    
                </Style>                            
            </TextBlock.Style>
        </TextBlock>

        <TextBlock FontStyle="Italic" FontSize="40" Text="{Localization:Translate Uid=Search_Start, Default=[Search]}" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" >
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}">
                   <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>                      
                          <MultiDataTrigger>
                               <MultiDataTrigger.Conditions>                                    
                                    <Condition Binding="{Binding ElementName=TasksListToDo, Path=Items.Count}" Value="0"/>
                                    <Condition Binding="{Binding SearchIsRunning}" Value="True"/>
                                    <Condition Binding="{Binding ElementName=TxtSearch, Path=Text, Converter={StaticResource CheckStringEmpty}}" Value="False"/>
                               </MultiDataTrigger.Conditions>
                               <Setter Property="Visibility" Value="Visible" />
                         </MultiDataTrigger>
                    </Style.Triggers>                    
                </Style>                            
            </TextBlock.Style>
        </TextBlock>
    </Grid>
</UserControls:ScrumUserControl>    